'use strict';
const bcrypt = require('bcryptjs');

module.exports = app => {
  const { STRING, INTEGER } = app.Sequelize;
  const Student = app.model.define(
    'student',
    {
      id: { type: INTEGER, primaryKey: true, autoIncrement: true },
        student_name: STRING(32),
        number: INTEGER(11),
        school_id: INTEGER(11),
      class_id: INTEGER(11),
      status: INTEGER(11),
        type: STRING(255),
        sex: STRING(255),
      password: STRING(255),
        age: INTEGER(11),
        email: STRING(255),
        phone: STRING(255),
        birthday: STRING(255),
    },
    {
      tableName: 'student',
      timestamps: true, // 启用时间戳(createdAt, updatedAt)
      updatedAt: false, // 不想要 updatedAt
      createdAt: 'created_at', // 想要  createdAt 但是希望名称叫做 created_at
    }
  );
    Student.associate = () => {
        const { School, Class } = app.model;
        Student.hasOne(School, {foreignKey: 'id', sourceKey: 'school_id'})
        Student.hasOne(Class, {foreignKey: 'id', sourceKey: 'class_id'})
    };
  return Student;
};
